from django.db import models
import time

# Create your models here.
class Product(models.Model):
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=255)
    type = models.ForeignKey('ProductType', on_delete=models.CASCADE, db_column='type')
    price = models.PositiveIntegerField(default=0)
    thumb = models.CharField(max_length=255)
    status = models.PositiveIntegerField(default=1)
    imgs = models.TextField()
    sales = models.PositiveIntegerField()
    max_buy_num = models.PositiveIntegerField()
    content = models.TextField()
    stock = models.PositiveIntegerField()
    ctime = models.PositiveIntegerField(default=time.time())
    utime = models.PositiveIntegerField(default=time.time())

    class Meta:
        app_label = 'product'
        managed = False
        db_table = 'pf_product'


class ProductType(models.Model):
    name = models.CharField(max_length=255)
    auth = models.PositiveIntegerField()
    ctime = models.PositiveIntegerField(default=time.time())
    utime = models.PositiveIntegerField(default=time.time())

    class Meta:
        app_label = 'product'
        managed = False
        db_table = 'pf_product_type'

class ProductBanner(models.Model):
    type = models.IntegerField()
    image = models.CharField(max_length=512, blank=True, null=True)
    url = models.CharField(max_length=512, blank=True, null=True)
    product_id = models.PositiveIntegerField(default=0)
    is_display = models.SmallIntegerField(default=1)
    sort = models.IntegerField(default=0)
    utime = models.IntegerField(default=time.time())
    ctime = models.IntegerField(default=time.time())

    class Meta:
        app_label = 'product'
        managed = False
        db_table = 'pf_banner'



